function [U] = cpdgevd(T,R,eig_s)
N = ndims(T);
size_tens=size(T);
[S,V,~] = hosvd(T);
[S, V] = cuthosvd(S, V, R);
if eig_s == 1
    [Apt,~] = eig(S(:,:,1).',S(:,:,2).');
else
    [Apt,~] = eig(S(:,:,2).',S(:,:,1).');
end
U = cell(1,N);
U{1} = V{1}/(Apt.');
T1 = reshape(T,size_tens(1),[]);
X = T1.'*conj(V{1})*Apt;
%LSKR
[U{3},U{2}]=LSKRF(X,size_tens(3),size_tens(2));
% for r = 1:R
%     [u,s,v] = svd(reshape(X(:,r),size_tens(2:end)));
%     U{2}(:,r) = u(:,1)*sqrt(s(1));
%     U{3}(:,r) = conj(v(:,1))*sqrt(s(1));
% end
U{1} = T1/(kr(U(end:-1:2)).');
end


